﻿var 
// Will speed up references to window, and allows munging its name.
window = this,
// Will speed up references to undefined, and allows munging its name.
undefined,
// Map over ajaxstack in case of overwrite
_AjaxStack = window.AjaxStack,

AjaxStack = window.A$ = window.AjaxStack = {};

//@requires Class to be defined first.
var staticMap =
{
	Class: Class, is: is, ArrayExt: ArrayExt, Environment: Environment, FormExt: FormExt,
	Html: Html, jQueryExt: jQueryExt, Key: Key, ObjectExt: ObjectExt, StringExt: StringExt,
	Reflection: Reflection, Quirks: Quirks, Script: Script, ResultEvent: ResultEvent, 
	Urn: Urn, Dto: Dto
};
for (var type in staticMap) Class.registerType("AjaxStack." + type, staticMap[type]);

AjaxStack.sys = sys = {
	'import': function(jsNamespace, intoScope)
	{
		var jsTypes = is.String(jsNamespace) ? window[jsNamespace] : jsNamespace;
		intoScope = intoScope || window;
		for (var type in jsTypes)
		{
			intoScope[type] = jsTypes[type];
		}
	},
	create: function(nsType, ctorArgs)
	{
		var ctor = Class.getConstructor(nsType);
		if (!ctor) return null;
		return new ctor(ctorArgs);
	},
	createFactoryFn: function(ctor)
	{
		return function() { return new ctor(); }
	}
};


function ASObject()
{
	if (!this.constructor.log)
	{
		this.constructor.log = new Logger(this.getType());
	}
	this.log = this.constructor.log;
}
ASObject.extend(Class, { type: 'AjaxStack.ASObject' },
	function(p)
	{
		var ctor = p.constructor;
		p.getFactoryFn = function() { return sys.createFactoryFn(this.constructor); }
	}
);

